package com.hhit.bigscreenbackmanage.controller.zlgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.entity.zlgl.TZlglActualMeasurement;
import com.hhit.bigscreenbackmanage.entity.zlgl.TZlglMonthlyMeeting;
import com.hhit.bigscreenbackmanage.entity.zlgl.TZlglSbdlsdtyzsfgcsbxm;
import com.hhit.bigscreenbackmanage.service.zlgl.TZlglActualMeasurementService;
import com.hhit.bigscreenbackmanage.service.zlgl.TZlglMonthlyMeetingService;
import com.hhit.bigscreenbackmanage.service.zlgl.TZlglQualitySupervisionService;
import com.hhit.bigscreenbackmanage.service.zlgl.TZlglSbdlsdtyzsfgcsbxmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 质量管理接口
 * 2021/7/20 15:20
 * caojie
 */
@RestController
@RequestMapping("/zlglController")
public class ZlglController {


    @Autowired
    private TZlglSbdlsdtyzsfgcsbxmService tZlglSbdlsdtyzsfgcsbxmService;

    @Autowired
    private TZlglActualMeasurementService tZlglActualMeasurementService;

    @Autowired
    private TZlglMonthlyMeetingService tZlglMonthlyMeetingService;

    @Autowired
    private TZlglQualitySupervisionService tZlglQualitySupervisionService;

    @RequestMapping("/getTZlglSbdlsdtyzsfgcsbxmAll")
    public Response getTZlglSbdlsdtyzsfgcsbxmAll(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglSbdlsdtyzsfgcsbxmService.getTZlglSbdlsdtyzsfgcsbxmAll(JSONObject));
        } catch (Exception e) {
            return Response.createResponseBySuccess("查询失败"+e.getMessage());
        }
    }

    /**
     * 查询月度例会
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getTZlglMonthlyMeetingAll")
    public Response getTZlglMonthlyMeetingAll(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglMonthlyMeetingService.getTZlglMonthlyMeetingAll(JSONObject));
        } catch (Exception e) {
            return Response.createResponseBySuccess("查询失败"+e.getMessage());
        }
    }

    /**
     * 查询实测实量
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getZlglActualMeasurementAll")
    public Response getZlglActualMeasurementAll(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglActualMeasurementService.getTZlglActualMeasurementAll(JSONObject));
        } catch (Exception e) {
            return Response.createResponseBySuccess("查询失败"+e.getMessage());
        }
    }

    /**
     * 导入月度例会
     * @param JSONObject
     * @return
     */
    @RequestMapping("/insertTZlglMonthlyMeeting")
    public Response insertTZlglMonthlyMeeting(@RequestBody JSONObject JSONObject) {
        Map<String, Object> stringObjectMap = new HashMap<>();
        try {
            stringObjectMap = tZlglMonthlyMeetingService.insertTZlglMonthlyMeeting(JSONObject);
            Boolean flag = (Boolean)stringObjectMap.get("flag");
            if(flag){
                return Response.createResponseBySuccess("新增成功",null);
            }else {
                return Response.createResponseByError("新增失败:"+null);
            }
        }catch (Exception e){
            return Response.createResponseByError("新增失败:"+e.getMessage());
        }
    }

    /**
     * 查询质量监督检查
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getTZlglQualitySupervision")
    public Response getTZlglQualitySupervision(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglQualitySupervisionService.getTZlglQualitySupervision(JSONObject));
        } catch (Exception e) {
            return Response.createResponseBySuccess("查询失败"+e.getMessage());
        }
    }

    /**
     * 新增质量监督检查
     * @param JSONObject
     * @return
     */
    @RequestMapping("/insertTZlglQualitySupervision")
    public Response insertTZlglQualitySupervision(@RequestBody JSONObject JSONObject) {
        Map<String, Object> stringObjectMap = new HashMap<>();
        try {
            stringObjectMap = tZlglQualitySupervisionService.insertTZlglQualitySupervision(JSONObject);
            Boolean flag = (Boolean)stringObjectMap.get("flag");
            if(flag){
                return Response.createResponseBySuccess("新增成功",null);
            }else {
                return Response.createResponseByError("新增失败:"+null);
            }
        }catch (Exception e){
            return Response.createResponseByError("新增失败:"+e.getMessage());
        }
    }

    /**
     * 实测实量统计数据
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getScslTj")
    public Response getScslTj(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglActualMeasurementService.getScslTj(JSONObject));
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 绿色试点工程  统计
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getPilotProjectStatistics")
    public Response getPilotProjectStatistics(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglSbdlsdtyzsfgcsbxmService.getPilotProjectStatistics(JSONObject));
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 绿色低碳优质工程统计
     * @param JSONObject
     * @return
     */
    @RequestMapping("/getLsdtyzgcTj")
    public Response getLsdtyzgcTj(@RequestBody JSONObject JSONObject) {
        try {
            return Response.createResponseBySuccess("查询成功",tZlglSbdlsdtyzsfgcsbxmService.getLsdtyzgcTj(JSONObject));
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

}
